package com.xywh.dakaqiandao.mvp.ui.util;


import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.xywh.dakaqiandao.R;

public class GlideUtil {

    public static void loadImage(Context content, Object imgPath, ImageView imageView) {

        RequestOptions requestOptions = new RequestOptions()
                .placeholder(R.mipmap.ic_launcher)
                .error(R.mipmap.ic_launcher)
                .fallback(R.mipmap.ic_launcher);

        Glide.with(content).load(imgPath).apply(requestOptions).into(imageView);
    }

    public static void loadImage(Context content, Object imgPath, ImageView imageView, int defaultImage) {

        RequestOptions requestOptions = new RequestOptions()
                .placeholder(defaultImage)
                .error(defaultImage)
                .fallback(defaultImage);

        Glide.with(content).load(imgPath).apply(requestOptions).into(imageView);
    }

    public static void loadRoundImage(Context content, Object imgPath, ImageView imageView, int defaultImage) {


        RoundedCorners roundedCorners = new RoundedCorners(30);


        RequestOptions requestOptions = RequestOptions.bitmapTransform(roundedCorners).override(300, 300)
                .circleCrop()
                .placeholder(defaultImage)
                .error(defaultImage)
                .fallback(defaultImage);

        Glide.with(content).load(imgPath).apply(requestOptions).into(imageView);
    }
}
